home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _663DC9746F1C446B8A5C2D6CB144FA3C < prev    next >
Text File  |  2005-03-08  |  1KB  |  66 lines

  1. //sky vertex shader:
  2. //moves texture coordinates with time
  3. //generates textures coordinates for 1 layer
  4.  
  5. //Luke Lenhart
  6. //(C)2004-2005 Digipen Institute of Technology
  7.  
  8. //brightness of sky
  9. float4 skyColor;
  10.  
  11. //translucency to draw layer at
  12. float alpha;
  13.  
  14. //world,view,projection transform
  15. float4x4 matWorldViewProj;
  16.  
  17. //current time (in seconds) since whenever
  18. float curTime;
  19.  
  20. //shader input
  21. struct VS_INPUT
  22. {
  23.     float4 Pos : POSITION;
  24.     float2 Tex0 : TEXCOORD0;
  25. };
  26.  
  27. //shader output
  28. struct VS_OUTPUT
  29. {
  30.     float4 Pos : POSITION;
  31.     float4 Color : COLOR;
  32.     float2 Tex0 : TEXCOORD0;
  33. };
  34.  
  35. //shader code
  36. VS_OUTPUT VShader(VS_INPUT In)
  37. {
  38.     VS_OUTPUT Out;
  39.     
  40.     //calc transformed position
  41.     Out.Pos=mul(matWorldViewProj,In.Pos);
  42.     
  43.     float2 postxt=float2(In.Pos.x,In.Pos.y);
  44.     Out.Tex0=postxt*1.0f+float2(curTime*-.07,curTime*.03);
  45.     
  46.      //make vert color
  47.     Out.Color=skyColor;
  48.     Out.Color.a=1.0f;
  49.     
  50.     //if z is near 0, fade it out
  51.     if (In.Pos.z<=0.0f)
  52.     {
  53.         Out.Color.a=0.0f;
  54.     }
  55.     else if (In.Pos.z<0.05f)
  56.     {
  57.         Out.Color.a=0.35f;    
  58.     }
  59.     
  60.     //apply alpha parameter
  61.     Out.Color.a*=alpha;
  62.  
  63.     //spit out the results
  64.     return Out;
  65. }
  66.